package com.xone.xapp;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.json.JSONObject;

public class UserInfo {
	
	public static boolean login = false;
	public static boolean alevelUser = false;
	public static boolean blevelUser = false;
	public static boolean clevelUser = false;
	
	public static Map<String, String> userMap = new HashMap<String, String>();
	
	public static void initUserMap(String user) {
		JSONObject object = JSONUtils.getJSONObjectFromString(user);
		alevelUser = JSONUtils.getBooleanFromJSONObject(object, "alevelUser");
		blevelUser = JSONUtils.getBooleanFromJSONObject(object, "blevelUser");
		clevelUser = JSONUtils.getBooleanFromJSONObject(object, "clevelUser");
		JSONObject usermap = JSONUtils.getJSONObjectForKey(object, "userMap");
		Iterator iterator = usermap.keys();
		while (iterator.hasNext()) {
			String key = (String)iterator.next();
			if (!usermap.isNull(key)) {
				userMap.put(key, JSONUtils.getStringFromJSONObject(usermap, key));
			}
		}
	}

}
